#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <aclconio.h>
#include <define.h>
#include <transact.h>
#include <tran.h>
#include <gds.h>
#include <sizes.h>
#include "ConfProto.h"
#include "tblutil.h"
#include <\SOFTPAY\Ver30\source\include\sizes.h>
#include <\SOFTPAY\Ver30\HostSrc\citisrc\citiids.h>
#include <\SOFTPAY\Ver30\HostSrc\cpacsrc\cpacids.h>
#include <confio.h>

#include <\SOFTPAY\Ver30\source\include\CPT.h>



static void *storeFromStruct;

static int recordNum;
void registerCPT(void *ptr)
{
	 storeFromStruct = ptr;
}

void *dealWithAddressBoundary(void*address);
int	inLoadCPTRecFromStruct (int inRecNumber, void *vdStruct)
{
	int inRet;
	char* tmp = (char*)vdStruct;

	registerCPT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inLoadConfRec(CPT_FILENAME, SIZE_CPT_REC, inRecNumber, vdStruct);

	recordNum = inRecNumber;
	return inRet;
}

void vdRestoreCPTRecFromStruct(void *vdStruct)
{
	registerCPT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	memcpy((char *) pvdGetCPTRec(), vdStruct, SIZE_CPT_REC);

}

void vdCopyCPTRecFromStruct(void *vdStruct)
{
	registerCPT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
		memcpy(vdStruct, (char *) pvdGetCPTRec(), SIZE_CPT_REC);

}

int	inSaveCPTRecFromStruct (int inRecNumber,  void *vdStruct)
{
	int inRet;

	registerCPT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(CPT_FILENAME, SIZE_CPT_REC, inRecNumber, (char *) vdStruct);

	return inRet;
}

int	inUpdateCPTRecFromStruct (void *vdStruct)
{
	int inRet;

	registerCPT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(CPT_FILENAME, SIZE_CPT_REC, recordNum, (char *) vdStruct);

	return inRet;
}

